package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.util.ShiroUtils;
import com.ruoyi.system.domain.BizDuty;
import com.ruoyi.system.domain.BizOndutyVO;
import com.ruoyi.system.domain.SysDept;
import com.ruoyi.system.service.IBizDutyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 排班设置Controller
 * 
 * @author fmi110
 * @date 2021-07-25
 */
@Controller
@RequestMapping("/system/onduty")
public class BizOnDutyController extends BaseController
{
    private String prefix = "system/onduty";

    @Autowired
    private IBizDutyService bizDutyService;

    @GetMapping()
    public String onduty(ModelMap mmap)
    {
        SysDept dept = ShiroUtils.getSysUser().getDept();
        mmap.put("dept",dept );
        return prefix + "/onduty";
    }


    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizDuty bizDuty)
    {
//        startPage();
//        List<BizOndutyVO> list = bizDutyService.selectBizonDutyList(bizDuty);
        List<BizDuty> list = bizDutyService.selectBizDutyListAll(bizDuty);
        return getDataTable(list);
    }
    /**
     * 导出
     */
    @Log(title = "每日值班", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizDuty bizDuty)
    {
        List<BizOndutyVO> list = bizDutyService.selectBizonDutyList(bizDuty);
        ExcelUtil<BizOndutyVO> util = new ExcelUtil<BizOndutyVO>(BizOndutyVO.class);
        return util.exportExcel(list, "onduty");
    }

}
